package com.synjones;

import android.os.Handler;
import android.os.Looper;
import android.support.annotation.NonNull;

import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class AppExecutors {
    public static ExecutorService ioExecutor = Executors.newFixedThreadPool(4);
    public static MainThreadExecutor mainThread = new MainThreadExecutor();
    public static class MainThreadExecutor implements Executor {
        private Handler mainThreadHandler = new Handler(Looper.getMainLooper());
        public void schedule(Runnable command,long delay){
            mainThreadHandler.postDelayed(command, delay);
        }

        @Override
        public void execute(@NonNull Runnable runnable) {
            mainThreadHandler.post(runnable);
        }
    }

}
